package com.fjwt.gz.proxy.ctrl.lite.feedback;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.dto.LiteFeedbackDTO;
import com.fjwt.gz.db.vo.LiteFeedbackVO;
import com.fjwt.gz.proxy.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.LiteFeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Slf4j
@RequestMapping("/api/liteFeedback")
public class LiteFeedBackController extends CommonCtrl {

    @Autowired
    private LiteFeedbackService liteFeedbackService;
    /**
     * 机构查询用户反馈列表
     */
    @GetMapping
    public ApiRes list(){
        LiteFeedbackDTO liteFeedbackDTO = getObject(LiteFeedbackDTO.class);
        IPage<LiteFeedbackVO> page = liteFeedbackService.queryList(getIPage(true), liteFeedbackDTO);
        return ApiRes.page(page);
    }

    /**
     * 反馈回复
     */
    @PostMapping("/reply")
    public ApiRes reply(){
        LiteFeedbackDTO liteFeedbackDTO = getObject(LiteFeedbackDTO.class);
        log.info("反馈id:{},回复内容:{}",liteFeedbackDTO.getLiteFeedbackId(),liteFeedbackDTO.getFeedbackReply());
        liteFeedbackService.reply(liteFeedbackDTO);
        return ApiRes.ok();
    }
}
